//
//  StudyModel.swift
//  SafeFoodManagerDemo
//
//  Created by 振轩 on 2018/4/11.
//  Copyright © 2018年 bob. All rights reserved.
//
//
import Foundation
class CateMode: NSObject  {
    @objc var  code:NSInteger = 0
    @objc var msg:String?
    @objc var data:[AnyObject]?{
        didSet{
            
             var datas:[Categorys] = [Categorys]()
            guard let dataD:[[String:AnyObject]] = data as? [[String : AnyObject]] else {
                return
            }
            
            for da in dataD{
               let dat = Categorys.init(DIC: da )
                datas.append(dat)
            }
            
            data = datas
        }
        
    }
    
 convenience init(DIC:[String:AnyObject]) {
        self.init()
        
        setValuesForKeys(DIC)
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
    
}

class Categorys: NSObject {
    @objc var id:NSInteger = 0
    @objc var name:String?
    @objc var child:[AnyObject]?{
        
        didSet{
            var arrays:[Cate] = [Cate]()
            
            for ch in child!{
                
                let catt = Cate(DIC: ch as! [String : AnyObject])
                arrays.append(catt)
            }
            child = arrays
       }
    }

    convenience init(DIC:[String:AnyObject]) {
        self.init()
        
        setValuesForKeys(DIC)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
}
class Cate: NSObject {
    
    @objc var id:NSInteger = 0
    @objc var name:String?
    convenience init(DIC:[String:AnyObject]) {
        self.init()
        
        setValuesForKeys(DIC)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
}
//课程分类返回的model
///--------------------

///--------------课程列表------------------

 //课程列表请求模型。
class CourseListReq: NSObject {
    
    var type:NSInteger = 2
    var catId:NSInteger = 0
    var pageOn:NSInteger = 1
    var pageSize:NSInteger = 20
    var currentPage:NSInteger = 1
    
    func  getDic()->[String:AnyObject]{
        var params:[String:AnyObject] = [String:AnyObject]()
        
        params["type"] = self.type as AnyObject
        params["catId"] = catId as AnyObject
        params["pageOn"] = pageOn as AnyObject
        params["pageSize"] = pageSize as AnyObject
        params["currentPage"] = currentPage as AnyObject
        return params 
    
    }
}

class CourseListMode: NSObject  {
    @objc var  code:NSInteger = 0
    @objc var msg:String?
    @objc var data:[AnyObject]?{
        didSet{
            var arrays :[ArticleMode] = [ArticleMode]()
            
            
            for d in data!{
                let a :ArticleMode   = ArticleMode.init(DIC: d as! [String : AnyObject])
                arrays.append(a)
                
            }
            
            data = arrays
        }
        
        
    }
    @objc var totalRecord:NSInteger = 1
    convenience init(DIC:[String:AnyObject]) {
        self.init()
        
        setValuesForKeys(DIC)
    }
    
}


class ArticleMode: NSObject {
    @objc var id:NSInteger = 0
    @objc var title:String?
    @objc var intro:String?//简述
    @objc var collectNum:NSInteger = 0
    @objc var likeNum:NSInteger = 0
    @objc var viewNum:NSInteger = 0
    @objc var thumb:String?
    @objc var addDate:String?
    @objc var type:NSInteger = 0
    @objc var ROW_NUMBER:String?
    @objc var isSelect:Bool =  false
    
    convenience init(DIC:[String:AnyObject]) {
        self.init()
        setValuesForKeys(DIC)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
}





///--------------课程列表------------------



////-------------课程详情------------------

class CourseDetail: NSObject {
    @objc var code:NSInteger = 0
    @objc var msg:String?
    @objc var data:AnyObject?{
        
        didSet{
            
            let mode = ArticleDetail.init(DIC: data as! [String : AnyObject])
            data  = mode
            
            
        }
        
    }
    
    convenience init(DIC:[String:AnyObject]) {
        self.init()
        
        setValuesForKeys(DIC)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
}

class ArticleDetail: articleSub {
    @objc   var cellHeight:Float = 0{
        didSet{
           // NotificationCenter.default.post(name: NSNotification.Name.init("refresh"), object: nil)
            
            
        }
        
        
    }
    @objc   var content:String?
    @objc   var videoUrl:String?
    @objc   var isCollect: NSInteger = 0
    @objc   var isLike: NSInteger = 0
 
    @objc var relatedList:[AnyObject]?{
        didSet{
            
            var arrays = [videoSub]()
            for sub in relatedList!{
                
                let s = videoSub.init(DIC: sub as! [String : AnyObject])
                arrays.append(s)
                
            }
            relatedList = arrays
        }
        
    }
    
    @objc var attachFiles:[AnyObject]?{
        didSet{
            
            var atts = [AttatchMode]()
            for sub in attachFiles!{
                
                let s = AttatchMode.init(DIC: sub as! [String : AnyObject])
                atts.append(s)
                
            }
            attachFiles = atts
        }
        
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
}

///附件模型。
class AttatchMode: NSObject {
    @objc   var fileName:String?
    @objc   var fileExt:String?
    @objc   var filePath:String?
    @objc   var fileSize:String?
    convenience init(DIC:[String:AnyObject]) {
        self.init()
        
        setValuesForKeys(DIC)
    }
}


////-------------课程详情------------------


///------------------播放记录的模型--------------------

class PlayRecordInfoMode: NSObject {
    @objc var code:NSInteger = 0
    @objc var totalRecord:NSInteger = 0
    @objc var msg:String?
    @objc var data:[AnyObject]?{
        
        didSet{
            var arrays:[PlayRecordModel] = [PlayRecordModel]()
            for d in data!{
                let modep =  PlayRecordModel.init(DIC: d as! [String : AnyObject])
                arrays.append(modep)
                
            }
            data = arrays
            
        }
        
    }
    
    convenience init(DIC:[String:AnyObject]) {
        self.init()
        
        setValuesForKeys(DIC)
    }
}

class PlayRecordModel: NSObject {
   @objc  var id:NSInteger = 0
   @objc var title:String?
   @objc var thumb:String?
   @objc var addDate:String?
   @objc var type:NSInteger = 0
   @objc var totalPlayTime:NSInteger = 0
   @objc var currentPlayTime:NSInteger = 0
   @objc  var progress:NSInteger = 50
   @objc var ROW_NUMBER:NSInteger = 0
    convenience init(DIC:[String:AnyObject]) {
        self.init()
        
        setValuesForKeys(DIC)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
}












///------------------播放记录--------------------
